
import 'dart:isolate';

import 'package:flutter/material.dart';

class TapButton extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'asdf',
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('tap button'),
        ),
        body: Builder(
          builder: (BuildContext context){
            return new Center(
              child: new InkWell(
                onTap: (){
                  final snack = new SnackBar(content: new Text('tap'));
                  Scaffold.of(context).showSnackBar(snack);
                },
                child: new Container(
                  padding: new EdgeInsets.all(22.0),
                  decoration: new BoxDecoration(
                    color: Colors.yellow,
                    borderRadius: new BorderRadius.circular(2.0),
                  ),
                  child: new Text('My Button'),
                ),
              ),
            );
          },
        )
      ),
    );
  }
}

class RotateButton extends StatefulWidget{
  
  @override
  _RotateState createState() {
    return _RotateState();
  }
}

class _RotateState extends State<RotateButton> with TickerProviderStateMixin{

  AnimationController controller;
  CurvedAnimation curve;
  
  @override
  void initState() {
    super.initState();
    controller = new AnimationController(duration : const Duration(milliseconds: 500), vsync: this);
    curve = CurvedAnimation(parent: controller, curve: Curves.easeIn);
  }
  
  @override
  Widget build(BuildContext context) {
    return new Center(
      child: GestureDetector(
        child: new RotationTransition(
          turns: curve,
          child: FlutterLogo(
            size: 200.0,
          ),
        ),
        onDoubleTap: (){
          if(controller.isCompleted){
            controller.reverse();
          }else{
            controller.forward();
          }
        },
      ),
    );
  }
}


